home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
DEMON
/
LANGUAGE
/
POTSRC.ARC
/
src
/
c
/
POT_Compil
< prev
next >
Wrap
Text File
|
1995-05-06
|
2KB
|
142 lines
#include <pOtRTL.h>
#include "POT.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#ifdef __sun__
#define atexit(x) on_exit(x,NULL)
# ifndef L_tmpnam
# define L_tmpnam 1024
# endif
#endif
#ifdef __MSDOS__
# ifdef __TURBOC__
extern unsigned _stklen = 32768;
# endif
#endif
#ifdef __riscos
# define unlink remove
#include "kernel.h"
#include <string.h>
#define DDE_Prefix 0x42580
static int home_set = 0;
static void set_home(const char *path)
{
_kernel_swi_regs regs;
char buffer[512];
if (*path == '@') return;
strcpy(buffer, path);
strcat(buffer, ".^.^.");
/* fprintf(stderr, "Home: %s\n", &buffer); */
regs.r[0] = (int) &buffer;
if (_kernel_swi(DDE_Prefix, ®s, ®s) == NULL)
home_set = 1;
return;
}
static void unset_home(void)
{
if (home_set) {
_kernel_swi_regs regs;
regs.r[0] = 0;
(void)_kernel_swi(DDE_Prefix, ®s, ®s);
}
return;
}
#endif
pOt_LONGINT pOt__gc_heapthreshold = 65536;
static FILE *parfp;
void catch(signo)
int signo;
{
switch(signo) {
case SIGINT: pOt__halt(__FILE__,__LINE__,22); break;
case SIGFPE: pOt__halt(__FILE__,__LINE__,14); break;
default: pOt__halt(__FILE__,__LINE__,16); break;
}
}
static void rmparfile()
{
fclose(parfp);
unlink(pOt__parfilename);
free(pOt__parfilename);
#ifdef __riscos
unset_home();
#endif
}
int main(int argc, char *argv[])
{
FILE *nestedfp;
int ch;
parfp = NULL;
nestedfp = NULL;
signal(SIGINT, catch);
signal(SIGFPE, catch);
if((pOt__parfilename = malloc(L_tmpnam))==NULL) {
fprintf(stderr, "%s\n", "Not enough memory to start the program.");
exit(255);
}
tmpnam(pOt__parfilename);
parfp = fopen(pOt__parfilename, "w");
if(parfp == NULL) {
fprintf(stderr, "%s %s.\n", "Cannot create ", pOt__parfilename);
exit(255);
}
#ifdef __riscos
/* fprintf(stderr, "File: %s\n", argv[argc - 1]); */
set_home(argv[argc - 1]);
#endif
while(*(++argv)) {
#ifdef __riscos
if((*argv)[0] == '!') {
#else
if((*argv)[0] == '@') {
#endif
nestedfp = fopen((*argv + 1), "r");
if(nestedfp == NULL) fprintf(stderr, "%s not found.\n", (*argv + 1));
else {
while((ch = fgetc(nestedfp)) != EOF) fputc(ch, parfp);
fputc('\n', parfp);
fclose(nestedfp);
}
} else fprintf(parfp, "%s\n", *argv);
}
fclose(parfp);
atexit(rmparfile);
pOt_POT__body();
pOt_Compile_POT();
exit(0);
return 0;
}